package Controller.Actions.Get;

import Controller.*;
import java.io.*;
import java.net.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import Model.Beans.Results.*;
import Model.Beans.*;
import Model.QBE.*;

public class GetCourseAction implements Action {
    
    private String name;
    
    public GetCourseAction() 
    {
        this.name = "GetCourse";
    }
    
    public String getName()
    {
        return name;
    }
    
    public void perform(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException
    {
        CourseModel cmodel = new CourseModel();
        String id = request.getParameter("id");
        
        Course course = new Course();
        
        course = cmodel.search_by_id(id);
        response.setContentType("text/xml");
        response.setHeader("Cache-Control", "no-cache");
        
        if(course != null)
        {
            response.getWriter().write(course.toXML());
        }
        else
        {
            Course tmp = new Course();
            response.getWriter().write(tmp.toXML());
        }
    }
}
